package src.NPCs;

public class NPC extends NPCInstance
{
    public NPC(int type, int index)
    {
        npcType = type;
        npcIndex = index;
    }

    public void process()
    {
        /*Updates every 600 ms.*/
        if(combatDelay > 0)
        {
            combatDelay--;
        }
        if(respawnDelay > 0 && isDead)
        {
            respawnDelay--;
        }
        if(!randomWalk && isUnderPlayerAttack)
        {
            NPCAttack na = new NPCAttack(this);
            na.attackPlayer();
            na = null;
        }
    }

    public void requestAnim(int animId, int animD)
    {
        animRequest = animId;
        animDelay = animD;
        animUpdateRequired = true;
        updateRequired = true;
    }

    public void requestText(String message)
    {
        speakText = message;
        animUpdateRequired = true;
        speakTextUpdateRequired = true;
    }

    public void requestGFX(int gfxId, int gfxD)
    {
        gfxRequest = gfxId;
        gfxDelay = gfxD;
        gfxUpdateRequired = true;
        updateRequired = true;
    }

    public void requestFaceCoords(int X, int Y)
    {
        faceCoordsX = 2*X+1;
        faceCoordsY = 2*Y+1;
        faceCoordsUpdateRequired = true;
        updateRequired = true;
    }

    public void appendHit(int damage, int posion)
    {
        if(damage > currentHP)
        {
            damage = currentHP;
        }
        currentHP -= damage;
        if(currentHP <= 0)
        {
            currentHP = 0;
            isDead = true;
        }
        hitDiff1 = damage;
        posionHit1 = posion;
        hit1UpdateRequired = true;
        updateRequired = true;
    }
}